package JDBCDemo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
    入门
*/
public class Demo01{
    public static void main(String[] args) throws Exception {
        //1.注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");

        //2.获取连接
        String url = "jdbc:mysql://127.0.0.1:3306/mytest";
        String username = "root";
        String password = "123456";
        Connection con = DriverManager.getConnection(url,username,password);

        //3.定义SQL语句
        String sql = "update account set money = 2000 where name = '张三'";

        //4.获取执行sql的对象 Statement
        Statement stmt = con.createStatement();

        //5.执行sql
        int i = stmt.executeUpdate(sql);
        //返回影响函数
        System.out.println(i);

        //释放资源
        stmt.close();
        con.close();
    }
}
